@echo off
echo 正在编译贪吃蛇游戏...

REM 尝试使用MSBuild
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" SnakeGame.sln /p:Configuration=Debug /p:Platform="Any CPU"
    goto :end
)

if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe" SnakeGame.sln /p:Configuration=Debug /p:Platform="Any CPU"
    goto :end
)

if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" SnakeGame.sln /p:Configuration=Debug /p:Platform="Any CPU"
    goto :end
)

if exist "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" SnakeGame.sln /p:Configuration=Debug /p:Platform="Any CPU"
    goto :end
)

if exist "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" SnakeGame.sln /p:Configuration=Debug /p:Platform="Any CPU"
    goto :end
)

if exist "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" SnakeGame.sln /p:Configuration=Debug /p:Platform="Any CPU"
    goto :end
)

echo 未找到MSBuild，尝试使用dotnet...
dotnet build

:end
if exist "bin\Debug\SnakeGame.exe" (
    echo 编译成功！
    echo 可执行文件位置: bin\Debug\SnakeGame.exe
) else (
    echo 编译失败！
)
pause 